const fs = require('fs')
const path = require('path')

fs.readFile(
  path.join(
    __dirname,
    './07-含邮箱网页/大家好，我是木木，要资料的留下邮箱.html'
  ),
  'utf8',
  (err, data) => {
    if (err) return console.log('读取文件失败')
    const emailReg = /\w+@\w+\.(com|cn|org)/g
    let result
    while (true) {
      result = emailReg.exec(data)
      if (!result) return
      console.log(result[0])
    }
  }
)
